﻿<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
    <title>Preclinic - Medical & Hospital - Bootstrap 4 Admin Template</title>
    <link rel="stylesheet" type="text/css" href="/templates/assets/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/templates/assets/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/templates/assets/css/style.css">
    <!--[if lt IE 9]>
		<script src="/templates/assets/js/html5shiv.min.js"></script>
		<script src="/templates/assets/js/respond.min.js"></script>
	<![endif]-->
    <script src="/templates/assets/js/crypto-js.js"></script>
    <script src="/templates/assets/js/jquery-3.2.1.min.js"></script>
    <script src="/templates/assets/js/popper.min.js"></script>
    <script src="/templates/assets/js/bootstrap.min.js"></script>
    <script src="/templates/assets/js/app.js"></script>
<%--    <%--%>
<%--        String loginMsg = (String) request.getAttribute("loginMsg");--%>
<%--        System.out.println("=============="+loginMsg);--%>
<%--    %>--%>
        <% String ke="thanks,pig4cloud"; %>
</head>

<script type="text/javascript">
    $(function() {

    });

    function btnSubmit(){
        var names = $("#username").val();
        if(names == ""){
            alert("用户名不能为空！");
            return false;
        }
        var pwd = $("#password").val();
        if(pwd == ""){
            alert("密码不能为空！");
            return false;
        }else {
            $("#password").val(encrypt(pwd));
        }

       loginform.submit();
    }


    function encrypt(data) {
        var ke = '<%=ke%>';
        var key = CryptoJS.enc.Utf8.parse(ke);
        var encrypted = CryptoJS.AES.encrypt(data, key, {
            iv: key,
            mode: CryptoJS.mode.CFB,
            padding: CryptoJS.pad.NoPadding
        });
        return encrypted.toString();
    }


</script>
<body>
    <div class="main-wrapper account-wrapper">
        <div class="account-page">
			<div class="account-center">
				<div class="account-box">
                    <form name="loginform" action="${pageContext.request.contextPath}/login/toLogin" method="post" class="form-signin">
						<div class="account-logo">
                            <a href="index.html"><img src="/templates/assets/img/logo-dark.png" alt=""></a>
                        </div>
                        <div class="form-group">
                            <label>Username</label>
                            <input type="text" id="username" name="username" autofocus="" class="form-control">
                        </div>
                        <div class="form-group">
                            <label>Password</label>
                            <input type="password" id="password" name="password" class="form-control">
                        </div>
                        <div  style="text-align: center;"><font style="color: red"><%=request.getAttribute("loginMsg") == null ? "" : request.getAttribute("loginMsg") %></font></div>
                        <div class="form-group text-right">
                            <a href="forgot-password.html">Forgot your password?</a>
                        </div>
                        <div class="form-group text-center">
                            <button type="button" onclick="btnSubmit();" class="btn btn-primary account-btn">Login</button>
                        </div>
                        <div class="text-center register-link">
                            Don’t have an account? <a href="register.html">Register Now</a>
                        </div>
                    </form>
                </div>
			</div>
        </div>
    </div>

</body>

</html>